{% extends 'inventory/base.html' %}
{% load crispy_forms_tags %}

{% block title %}
{% if level %}编辑会员等级{% else %}添加会员等级{% endif %} - {{ block.super }}
{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <h4 class="card-title mb-0">
                    {% if level %}
                    编辑会员等级: {{ level.name }}
                    {% else %}
                    添加会员等级
                    {% endif %}
                </h4>
                <a href="{% url 'member_level_list' %}" class="btn btn-outline-secondary btn-sm">
                    <i class="bi bi-arrow-left"></i> 返回列表
                </a>
            </div>
            <div class="card-body">
                <form method="post" novalidate>
                    {% csrf_token %}

                    <div class="row">
                        <div class="col-md-6 mb-3">
                            {{ form.name|as_crispy_field }}
                        </div>
                        <div class="col-md-6 mb-3">
                            {{ form.discount|as_crispy_field }}
                            <small class="text-muted">折扣率范围: 0.00-1.00 (0表示无折扣，1表示不打折)</small>
                        </div>
                    </div>
                    
                    <div class="mb-4">
                        {{ form.points_threshold|as_crispy_field }}
                        <small class="text-muted">会员积分达到此阈值时将自动升级到此等级</small>
                    </div>

                    <div class="d-grid gap-2 d-md-flex justify-content-md-end">
                        <a href="{% url 'member_level_list' %}" class="btn btn-light">取消</a>
                        <button type="submit" class="btn btn-primary">
                            {% if level %}保存更改{% else %}添加等级{% endif %}
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %} 